local BuffInst = class("BuffInst")
local GameUtils = require("utils.GameUtils")
local Vector3 = require("utils.Vector3")

function BuffInst:ctor(config, actor)
    self._config = config
    self._actor = actor
    local gameObject = GameUtils.InstantiateEmptyObject(self._config.name)
    local luaBehaviour = gameObject:AddComponent(typeof(CS.LuaBehaviour))
    luaBehaviour:SetScriptEnv(self)
    self._count = 1
end

function BuffInst:increaseCount()
    self._count = self._count + 1
end

function BuffInst:decreaseCount()
    self._count = self._count - 1
end

function BuffInst:getCount()
    return self._count
end

function BuffInst:awake()
    if self._config.effect ~= "" then
        local effect = G_ResourceManager:loadBuff(self._config.effect)
        local gameObject = GameUtils.instantiateTo(self.transform, effect)
        gameObject.transform.localPosition = Vector3.new(0, 0, 0)
        gameObject.transform.localScale = Vector3.new(1, 1, 1)
    end
    local bloodUI = self._actor:getBloodUI()
    local icon = require("gameLogic.fightSkill.show.BuffIcon").new(self._config)
    GameUtils.addChildTo(bloodUI.transform, icon.transform)
    icon.transform.localPosition = Vector3.new(0, -13, 0)
    icon.transform.localScale = Vector3.new(1, 1, 1)
    self._icon = icon
end

function BuffInst:start()
    self.transform.localEulerAngles = Vector3.new(0, 0, 0)
end

function BuffInst:update()
end

function BuffInst:getIcon()
    return self._icon
end

function BuffInst:remove()
    GameUtils.destroy(self._icon.gameObject)
    GameUtils.destroy(self.gameObject)
end

function BuffInst:onDestroy()
end

return BuffInst
